<!DOCTYPE html>
<html>
<head>
    <title>添加-权限菜单节点</title>
    {include file="common/inc_meta" /}
</head>
<body>
 <div id="wrapper">
    {include file="common/inc_menu" /}
       <div id="page-wrapper" class="gray-bg">
          {include file="common/inc_top" /}
            <div class="row wrapper border-bottom white-bg page-heading" style="padding-top:20px;font-weight: normal;">
                <div class="col-sm-4">
                    <h2 style="margin-bottom:10px;">权限菜单节点</h2>
                    <ol class="breadcrumb">
                        <li><a href="{$admin.index_page}">主页</a></li>
                        <li><a>权限</a></li>
                        <li class="active"><strong>添加</strong></li>
                    </ol>
                </div>
                <div class="col-lg-2"></div>
            </div>
            <div class="wrapper wrapper-content animated fadeInRight">
                

             <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                        <div class="ibox-content" style="padding:20px;">
                            <form class="form-horizontal" id="myForms">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">标题</label>
                                    <div class="col-sm-4"><input type="text" class="form-control" maxlength="20" id="vTitle"></div>
                                    <label class="col-sm-1 control-label">图标</label>
                                    <div class="col-sm-2"><input type="text" class="form-control" id="vIcon"></div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group"><label class="col-sm-2 control-label">上级</label>
                                    <div class="col-sm-4">
                                         <select class="form-control" id="vPid">
                                            <option value="0">无</option>
                                            {volist name="rulelist" id="vo"}
                                            <option value="{$vo.id}">{$vo.title}</option>
                                            {/volist}
                                         </select>
                                    </div>
                                   <label class="col-sm-1 control-label">类型</label>
                                   <div class="col-sm-2">
                                      <label class="checkbox-inline i-checks"> <input type="radio" value="menu" name="mtype" checked="true"> 菜单</label>
                                      <label class="checkbox-inline i-checks"> <input type="radio" value="file" name="mtype"> 节点</label>
                                   </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group"><label class="col-sm-2 control-label">URL路由</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" placeholder="/模块/控制器/方法" id="vUrl">
                                        <span class="help-block m-b-none">多个请使用英文“;”分号分隔，填写格式：/模块/控制器/方法，顶级菜单填写标识，如：menu_one、menu_two</span>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">排序</label>
                                    <div class="col-sm-2">
                                          <input type="text" class="form-control" maxlength="4" id="vSort">
                                          <span class="help-block m-b-none">排序值越大越靠前显示，输入整数</span>
                                    </div>
                                    <label class="col-sm-1 control-label">状态</label>
                                    <div class="col-sm-2">
                                       <label class="checkbox-inline i-checks-two"> <input type="radio" value="1" name="ustatus" checked="true"> 开启</label>
                                       <label class="checkbox-inline i-checks-two"> <input type="radio" value="0" name="ustatus"> 关闭</label>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">所属模块</label>
                                    <div class="col-sm-4">
                                		<select class="form-control" id="vModuleType">
                                		   {volist name="module_type_list" id="vo"}
                                		   <option value="{$vo.id}">{$vo.name}</option>
                                		   {/volist}
                                		</select>
                                	</div>
                                    <label class="col-sm-1 control-label">备注</label>
                                    <div class="col-sm-2"><input type="text" class="form-control" id="vRemark" value=""></div>
                                </div>
                                

                                <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-2">
                                        <a href="{:url('admin/authrule/index')}" class="btn btn-white">返回</a>&nbsp;&nbsp;&nbsp;&nbsp;
                                        <button class="btn btn-primary" type="button" id="saveButton">保存</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>









            </div>
     {include file="common/inc_footer" /}
     </div>
 </div>
<!-- Mainly scripts -->
{include file="common/inc_jsfile" /}

<!-- iCheck -->
<script src="__ADMIN__/js/plugins/iCheck/icheck.min.js"></script>
 <link href="__ADMIN__/searchableSelect/jquery.searchableSelect.css" rel="stylesheet" type="text/css">
 <script src="__ADMIN__/searchableSelect/jquery.searchableSelect.js"></script>
<script>
$(function(){
    $('select').searchableSelect();
   $('.i-checks,.i-checks-two').iCheck({
        checkboxClass: 'icheckbox_square-green',
        radioClass: 'iradio_square-green',
   });
   //保存
   $("#saveButton").click(function(){
     saveAction();
   });
   $('#vTitle').focus();
});
//保存
function saveAction()
{
 var param = {};
 param.v_title = $.trim($('#vTitle').val());
 param.v_icon = $.trim($('#vIcon').val());
 param.v_pid = $.trim($('#vPid').val());
 param.v_type = $.trim($("input[name='mtype']:checked").val());
 param.v_url = $.trim($('#vUrl').val());
 param.v_sort = $.trim($('#vSort').val());
 param.v_status = $.trim($("input[name='ustatus']:checked").val());
 param.v_module_type = $.trim($('#vModuleType').val());
 param.v_remark = $.trim($('#vRemark').val());
 if(param.v_title.length <= 0)
 {
   $('#vTitle').focus();
   layer.msg('请填写菜单/节点的标题', {time: 2000,anim: 6,shade:[0.4,'#000000']});
   return false;
 }
 if(param.v_url.length <= 0)
 {
   $('#vUrl').focus();
   layer.msg('请填写菜单/节点的URL路由', {time: 2000,anim: 6,shade:[0.4,'#000000']});
   return false;
 }
 _Admin.ajax("{:url('admin/authrule/add')}",param,function(d){
   if(d.err == '0')
   {
     $('#myForms')[0].reset();
     $('#vTitle').focus();
     layer.msg(d.msg, {time: 1000,shade:[0.4,'#000000']});
   }else{
     layer.msg(d.msg, {time: 2000,anim: 6,shade:[0.4,'#000000']});
   }
 });  
}
</script>
</body>
</html>
